using System;
using System.Collections.Generic;
using NmbpProject2.DataLayer;
using NmbpProject2.DboClasses;

namespace NmbpProject2.BusinessLayer
{
    public class CompetitionBL
    {
        #region "*** Private variables ***"

        //klasa za rad s podatkovnim slojem
        private readonly CompetitionDL _compDl = new CompetitionDL();

        #endregion

        #region "*** Methods ***"

        /// <summary>
        /// vraca sva natjecanja
        /// </summary>
        /// <returns></returns>
        public List<Competition> allCompetitions(string test)
        {
            return _compDl.allCompetitions(test);
        }

        /// <summary>
        /// zove brisanje natjecanja iz baze
        /// </summary>
        /// <param name="competition"></param>
        public void deleteCompetition(Competition competition)
        {
            _compDl.deleteCompetition(competition);
        }

        /// <summary>
        /// zove provjeru istovjetnosti za natjecanje po imenu i datumu
        /// </summary>
        /// <param name="name"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public bool isDuplicate(string name, DateTime dt)
        {
            var comp = new Competition(name, dt, null, null);
            return _compDl.isDuplicate(comp);
        }

        /// <summary>
        /// zove stvaranje novog natjecanja na podatkovnom sloju
        /// </summary>
        /// <param name="name"></param>
        /// <param name="date"></param>
        /// <param name="categories"></param>
        /// <param name="progLanguages"></param>
        public void newCompetition(string name, DateTime date, List<Category> categories,
                                   List<ProgLanguage> progLanguages)
        {
            _compDl.newCompetition(name, date, categories, progLanguages);
        }

        /// <summary>
        /// zove update podatkovnog sloja za natjecanje
        /// </summary>
        /// <param name="name"></param>
        /// <param name="date"></param>
        /// <param name="categories"></param>
        /// <param name="progLanguages"></param>
        /// <param name="competition"></param>
        public void updateCompetition(string name, DateTime date, List<Category> categories,
                                      List<ProgLanguage> progLanguages, Competition competition)
        {
            _compDl.updateCompetition(name, date, categories, progLanguages, competition);
        }

        #endregion
    }
}